<%@page import="cn.ysnk.clz.util.dateUtil.DateUtil"%>
<%@page import="cn.ysnk.clz.entity.menu.AdminSubMenu"%>
<%@page import="java.util.List"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<%
List<AdminSubMenu> menuList = (List<AdminSubMenu>)request.getAttribute("list");
String menuId = (String)request.getAttribute("menuId");
%>
</head>
<body>
	<div class="modal-header">
		<button type="button" class="close" data-dismiss="modal"
			aria-label="Close">
			<span aria-hidden="true">&times;</span>
		</button>
		<h4 class="modal-title" id="myModalLabel">选择图标</h4>
	</div>
	<div class="modal-body">
		<div class="default-padding container-fluid">
			<button type="button" onclick="addSubMenu()" class="btn btn-primary default-margin-bottom">新增菜单</button>
			<table class="table table-bordered table-hover">
				<thead>
					<tr>
						<th>序号</th>
						<th>菜单名称</th>
						<th>菜单图标</th>
						<th>菜单动作</th>
						<th>添加时间</th>
						<th>操作</th>
					</tr>
				</thead>
				<tbody>
				<%
				int index = 1;
			    for(AdminSubMenu menu:menuList){
			    %>
			    	<tr>
			    		<td><%=index++ %></td>
			    		<td><%=menu.getStr("name") %></td>
			    		<td>
				    		<div class="inline-block">
					    		<span class="glyphicon glyphicon-<%=menu.getStr("icon") %>" aria-hidden="true"></span>
					    	</div>
			    		</td>
			    		<td><%=menu.getStr("action") %></td>
			    		<td><%= DateUtil.DateToString(menu.getDate("updateTime"),"yyyy-MM-dd") %></td>
			    		<td>
			    			<button type="button" onclick="editSubMenu('<%=menu.getStr("id") %>')" class="btn btn-info">修改</button>
			    			<button type="button" onclick="deleteSubMenu('<%=menu.getStr("id") %>')" class="btn btn-warning">删除</button>
			    		</td>
			    	</tr>
			    <%
			    }
			    %>
				</tbody>
			</table>
		</div>
	</div>
	<div class="modal-footer">
		<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
	</div>
	<script type="text/javascript">
			
	function addSubMenu(){
		$("#myLargerModal").modal('hide');
		refreshTab('/adminMenu/subEditMenu?menuId=<%=menuId%>');
	}
	function editSubMenu(subMenuId){
		$("#myLargerModal").modal('hide');
		refreshTab('/adminMenu/subEditMenu?menuId=<%=menuId%>&subMenuId='+subMenuId);
	}
	function deleteSubMenu(subMenuId){
		var submit = function (v, h, f) {
		    if (v == 'ok')
		    	ajaxDataPost("/adminMenu/deleteSubMenu",{subMenuId:subMenuId},refreshAdmin,refreshAdmin);
		    return true; //close
		};
		$.jBox.confirm("确定删除该菜单吗？", "提示", submit);
	}
	</script>
</body>
</html>